package com.jiepos.mpos.common.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.jiepos.mpos.common.entity.App_Host_TermEntity;
import com.jiepos.mpos.core.dao.BaseDao;

/**
 * 
 * 
 * <p>标题: —— 主机终端表操作类</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @ProjectName:  [mpos] 
 * @Package com.jiepos.mpos.common.dao 
 * @author 张学涛
 * @version 1.0
 * @since 2017年9月29日上午10:19:42
 * @history（历次修订内容、修订人、修订时间等）
 */
@Repository
public class HostTermDao extends BaseDao<App_Host_TermEntity> {
	
	public void saveEntity(List paramList,String tablename){
		StringBuffer sql = new StringBuffer();
		sql.append("INSERT INTO ");
		sql.append(tablename);
		sql.append(" (host_term_uuid,mchnt_cd,term_id,term_nm,trf_mchnt_cd,trf_term_id,service_uuid,service_param_uuid,area_cd,");
		sql.append(" master_key_idx,master_key,mac_key,pin_key,trk_key,debit_minfee,debit_rate,debit_maxfee,");
		sql.append(" credit_minfee,credit_rate,credit_maxfee,sign_st,rec_st,rec_crt_ts,rec_upd_ts,rec_upd_usr_id,last_oper_in)");
		sql.append(" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
		update(sql.toString(), paramList);
	}
	
	
	public void updateEntity(List paramList,String tablename){
		StringBuffer sql = new StringBuffer();
		sql.append("UPDATE ");
		sql.append(tablename);
		sql.append(" SET mchnt_cd=?,term_id=?,term_nm=?,trf_mchnt_cd=?,trf_term_id=?,service_uuid=?,service_param_uuid=?,");
		sql.append(" area_cd=?,master_key_idx=?,master_key=?,mac_key=?,pin_key=?,trk_key=?,debit_minfee=?,");
		sql.append(" debit_rate=?,debit_maxfee=?,credit_minfee=?,credit_rate=?,credit_maxfee=?,sign_st=?,");
		sql.append(" rec_upd_ts=?,rec_upd_usr_id=?,last_oper_in=? WHERE rec_id=?");
		update(sql.toString(), paramList);
	}
	
	public Map getEntityById(String tablename,String host_term_uuid){
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT * FROM ");
		sql.append(tablename);
		sql.append(" where host_term_uuid='");
		sql.append(host_term_uuid).append("' and rec_st!='0'");
		return queryForMap(sql.toString());
	}

}
